package animation7.view.xiaomage.com.viewanimation7

import android.animation.ArgbEvaluator
import android.animation.ObjectAnimator
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        bt_alpha.setOnClickListener{
            val alphaObjectAnimator=ObjectAnimator.ofFloat(view,"alpha",0.5f,1f,0f)
            alphaObjectAnimator.duration=5000
            alphaObjectAnimator.start()

        }
        bt_rotation_x.setOnClickListener{
            val rotetionXObjectAnimator=ObjectAnimator.ofFloat(view,"rotationX",0f,270f,0f)
            rotetionXObjectAnimator.duration=5000
            rotetionXObjectAnimator.start()
        }
        bt_rotation_y.setOnClickListener{
            val rotationYObjectAnimator=
                    ObjectAnimator.ofFloat(view,"rotationY",0f,180f,0f)
            rotationYObjectAnimator.duration=5000
            rotationYObjectAnimator.start()
        }
        bt_rotation.setOnClickListener{
            val rotateObjectAnimator=ObjectAnimator.ofFloat(view,"rotation",0f,270f,0f)
            rotateObjectAnimator.duration=5000
            rotateObjectAnimator.start()
        }
        bt_translation_x.setOnClickListener{
            val translationXObjectAnimator=ObjectAnimator.ofFloat(view,"translationX",
                    0f,200f,-200f,0f)
            translationXObjectAnimator.duration=5000
            translationXObjectAnimator.start()
        }
        bt_translation_y.setOnClickListener{
            val translationYObjecyAnimator=ObjectAnimator.ofFloat(view,"translationY",
                    0f,200f,-200f,0f)
            translationYObjecyAnimator.duration=5000
            translationYObjecyAnimator.start()
        }
        bt_scale_x.setOnClickListener{
            val scaleXObjectAnimator=ObjectAnimator.ofFloat(view,"scaleX",
                    0f,3f,1f)
            scaleXObjectAnimator.duration=5000
            scaleXObjectAnimator.start()
        }
        bt_scale_y.setOnClickListener{
            val scaleYObjectAnimator=ObjectAnimator.ofFloat(view,"scaleY"
            ,0f,3f,1f)
            scaleYObjectAnimator.duration=5000
            scaleYObjectAnimator.start()
        }
        bt_begin.setOnClickListener{
            myPointView.doPointViewAnimation()
        }
        bt_background_color.setOnClickListener{
            val objectAnimator=ObjectAnimator.ofInt(view,"backgroundColor",
                    0xffff00ff.toInt(), 0xffffff00.toInt(), 0xffff00ff.toInt())
            objectAnimator.duration=5000
            objectAnimator.setEvaluator(ArgbEvaluator())
            objectAnimator.start()
        }
    }
}
